<?php

namespace App\Http\Controllers\Front;

use App\Http\Controllers\Controller;
use App\Services\Form\initFormData as InitFormData;
use Cache;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Cookie;

class Mobile extends Controller
{
    use \App\Traits\ApiTrait, \App\Traits\CacheTrait;
    public $curl;
    // 正式环境java接口基础URL
    public $apiBaseUri='api.crm.tanwin.cn/';
    // 测试环境java接口基础URL
    // public $apiBaseUri='192.172.3.139:8080/';
    private $apiLoginUri='ctm/v1/login';
    private $apiCodeUri='ctm/v1/getYzm';
    private $apiMsgCenterUri='information/list';
    private $apiMsgUnreadUri='information/listIsnotread';
    private $msgPageSize='100';
    private $msgPageNum='1';
    private $apiRegistUri='ctm/v1/register';
    private $apiMsgDetailUri='informationread/search';
    private $apiMsgDelUri='information/delete';
    private $apiProfileUpdateUri='ctm/v1/perfectPersonalInfos';
    private $apiProfileUri='ctm/v1/getPersonalinfo';
    private $apiDownUri='files/fileslist';
    private $apiDownCateUri='files/getPageManage';
    private $apiActivityUri='activity/futureActivityList';
    private $apiSignUri='activitydetail/signup';
    private $apiActivityInfoUri='activity/viewActivity';
    private $apiArticleListUri='article/findByProgramaId';
    private $apiArticleUri='article/selectById';

    public function __construct(Request $request, InitFormData $formData)
    {
        $this->curl = new \Ixudra\Curl\CurlService();
        $this->request = $request;
        $this->formData = $formData;
    }

    public function preIndex(Request $request){
      $viewData = [
          'seo' => $this->returnSeoInfo('m_index'),
      ];
      return \response()
           ->view('mobile.preIndex',$viewData);
    }

    public function index(Request $request){
      $viewData = [
          'seo' => $this->returnSeoInfo('m_index'),
      ];
      return \response()
           ->view('mobile.index',$viewData);
    }

    public function video(Request $request  ){
      $viewData = [
          'seo' => $this->returnSeoInfo('m_video'),
      ];
      return \response()
           ->view('mobile.video.index',$viewData);
    }
    public function apply(){
      $viewData = [
          'seo' => [
            'title'=>'电站申请',
            ]
      ];
      return view('mobile.applyAce',$viewData);
    }
    public function partnerMarket(){
      $viewData = [
          'seo' => [
            'title'=>'碳银合伙人',
            ]
      ];
      return view('mobile.partnerMarket',$viewData);
    }
    public function partnerIndustry(){
      $viewData = [
          'seo' => [
            'title'=>'产业合伙人',
            ]
      ];
      return view('mobile.partnerIndustry',$viewData);
    }
    public function projectIntro(){
      $viewData = [
          'seo' => [
            'title'=>'产品介绍',
            ]
      ];
      return view('mobile.projectIntro',$viewData);
    }
    public function report(){
      $viewData = [
          'seo' => [
            'title'=>'关于我们-运营报告',
            ]
      ];
      return view('mobile.report',$viewData);
    }

    public function info(Request $request){
      $id=$request->id;
      if($id!=0){
        try {
          $rqUrl=$this->apiBaseUri.$this->apiArticleUri;
          $rqData=['id'=>$id];
          $result=$this->curl->to($rqUrl)
          ->withOption('TIMEOUT', 10)
          ->withData($rqData)
          ->post();
          $viewData=json_decode($result,true);
          $viewData['seo']['title']='碳银网';
          return view('mobile.common.infoT', $viewData);
        } catch (Exception $e) {
          return response("哎呀出错了！联系管理员！");
        }
      }
      return response("哎呀出错了！联系管理员！");
    }
}
